<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <p class="bg-info text-center" style="padding: 8px;">补费扣费操作</p>
        <div class="row" style="margin-top:10px;">

        </div>
        <div class="row" style="margin-top:10px;">
          <label for="f_type" class=" col-sm-2 control-label">补费扣费类型:</label>
          <div class="col-sm-2 disabled" id="f_brand_spec">
            <v-select id="f_type"
            v-model="model.f_type"
            placeholder='请选择'
            :value.sync="model.f_type"
            :options='brandspec'
            close-on-select clear-button>
          </v-select>
          </div>
          <div  :class="[$v.f_money.required ? 'has-error' : 'has-success']">
            <label style="" for="f_money" class="col-sm-1 col-sm-offset-1 control-label">补费扣费金额:</label>
            <div class="col-sm-2">
              <input class="form-control " type="number" min = "0" v-model="model.f_money"
                v-validate:f_money='{required: true }' placeholder="0"  v-el:sk>
            </div>
          </div>
        </div>
        <div class="row" style="margin-top:10px;">
          <div :class="[$v.f_reason.required ? 'has-error' : 'has-success']">
            <label for="f_reason" class=" col-sm-2 control-label">备注:</label>
            <div class="col-sm-9">
              <textarea style="width:100%" class="form-control" v-model="model.f_reason" rows="3"
              v-validate:f_note='{required: true }' placeholder="备注"></textarea>
            </div>
          </div>
        </div>
      </form>
      <div style="text-align:right;margin-top:30px;margin-right:50px;">
        <button class="btn btn-success" @click="confirm()"  :disabled='!$v.valid' id='components-comOpe-othCha-确认'>确&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;认</button>
        <button class="btn btn-default" @click="clean()" style="width:80px;margin-left:20px;" id='components-comOpe-othCha-取消'>取&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;消</button>
      </div>
    </validator>
  </div>
</template>
<script>
import AppData from '../../stores/AppData'
import * as Util from '../Util'

export default {
  title: '补费扣费详情',
  data () {
    return {
      model: {
        f_type: ['补费'],
        f_money: 0
      },
      print: false,
      taxprint: false,
      isConfirm: true
    }
  },
  props: ['row'],
  ready () {
    console.log('kankanren', this.row)
    console.log('util', Util.f)
    console.log('time', Util.toStandardTimeString())
  },
  watch: {
  },
  methods: {
    confirm () {
      let data = {
        f_user_id: this.row.f_user_id,
        f_userinfo_id: this.row.f_userinfo_id,
        f_user_name: this.row.f_user_name,
        f_meternumber: this.row.f_meternumber,
        f_money: this.model.f_money,
        f_reason: this.model.f_reason,
        f_type: this.model.f_type[0],
        f_fillandcharge_date: Util.toStandardTimeString(),
        f_operat_type: this.model.f_type[0],
        f_describe: `${Util.f.name}对用户${this.row.f_user_name}进行${this.model.f_type[0]}操作`,
        f_state: '有效',
        f_operator: Util.f.name,
        record_userinfo: this.row.f_userinfo_id,
        f_filiale: Util.f.f_fengongsi,
        f_outlets: Util.f.f_parentname
      }
      console.log('bufeikoufei---data', data)
      this.$resetpost('rs/entity/t_record', data, {resolveMsg: `${this.model.f_type[0]}成功`, rejectMsg: '补费扣费失败，请检查系统是否正常！'}).then(
        (res) => {
          console.log('--------res', res)
          this.clean()
        }
      )
    },
    clean () {
      console.log(111111)
      this.$parent.clean()
    }
  },
  computed: {
    brandspec () {
      return [{label: '补费', value: '补费'}, {label: '扣费', value: '扣费'}]
    },
    chargetype () {
      return AppData.getParam('打印格式')
    }
  }
}
</script>

<style>
</style>
